package com.mccken.practice.top100.Top_30$.Top_34;

import java.util.ArrayList;
import java.util.List;

import com.mccken.practice.top100.TreeNode;

/**
 * @program: mccken-collect
 * @description:
 * @author: mccken
 * @create: 2024-03-04 23:20
 **/
public class InorderTraversal {

	public List<Integer> inorderTraversal(TreeNode root) {

		List<Integer> list = new ArrayList<>();
		inorderTraversal(root, list);
		
		return list;
	}

	private void inorderTraversal(TreeNode node, List<Integer> list) {
		if (node == null) {
			return;
		}

		inorderTraversal(node.left,list);
		list.add(node.val);
		inorderTraversal(node.right, list);
	}

}
